package com.jbp.service.impl;

import com.jbp.dao.PrizeDeployDao;
import com.jbp.exception.RRException;
import com.jbp.model.PrizeDeploy;
import com.jbp.service.PrizeDeployService;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jbp.utils.PageUtils;
import com.jbp.utils.Query;



@Service
public class PrizeDeployServiceImpl extends ServiceImpl<PrizeDeployDao, PrizeDeploy> implements PrizeDeployService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<PrizeDeploy> page = this.page(
                new Query<PrizeDeploy>().getPage(params),
                new QueryWrapper<PrizeDeploy>()
        );

        return new PageUtils(page);
    }

    @Override
    public PrizeDeploy getByPoolType(String poolType){
        QueryWrapper<PrizeDeploy> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("pool_type", poolType);
        queryWrapper.eq("state", "putong");
        PrizeDeploy one = getOne(queryWrapper);
        if (one==null) {
            throw  new RRException("奖池不存在");
        }
        return one;
    }
}
